﻿using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Collections.Generic;
using Model;
using System.Xml.Linq;

namespace Control
{
    /// <summary>
    /// RioCMS CRUD para Tabelas
    /// </summary>
    [WebService(
      Name = "TabelasServices",
      Description = "RioCMS CRUD Tabelas",
      Namespace = "RioCMSControl"
  )]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    public class TabelasServices : System.Web.Services.WebService
    {
        private MGTabelas mg = new MGTabelas();

        [WebMethod(Description = "Retorna uma lista com todos as Tabelas")]
        public List<Tabela> listar()
        {
            if (!this.mg.autenticar())
            {
                return null;
            }
            else
            {
                return this.mg.listar();
            }
        }
        [WebMethod(Description = "Adicona uma nova Tabela")]
        public bool adicionar(String nome, String descricao)
        {

            if (!this.mg.autenticar())
            {
                return false;
            }
            else
            {
                return this.mg.adicionar(nome, descricao);
            }
        }

        [WebMethod(Description = "Remove uma tabela")]
        public bool remover(uint id)
        {
            if (!this.mg.autenticar())
            {
                return false;
            }
            else
            {
                return this.mg.remover(id);
            }
        }
    }
}
